/*const router = {
	"/refreshToken": {
		method: "GET",
		rule: ""
	},
}*/
const router = {
	// 唯一不验证token接口
	"login.post": "username:required,password:required",
	//  公共api接口
	"test": "name:required",
	"qiniutoken.get": "",
	// 用户模块
	"refreshtoken.get": "",
	"loginout.post": "",
	"resetsuper": "",
	"adminadd.post": "username:required,password:required,avatarUrl:required,tel:required|tel",
	"admindelete.post": "_id:required",
	"adminupdate.post": "_id:required",
	"adminlist.get": "",
	// 用户
	"userlist.get": "",
	// 广告模块
	"adveradd.post": "url:required,sort:required",
	"adverdelete.post": "_id:required",
	"adverupdate.post": "_id:required",
	"adverlist.get": "",
	// 轮播图模块
	"banneradd.post": "",
	"bannerdelete.post": "_id:required",
	"bannerupdate.post": "_id:required",
	"bannerlist.get": "",
	// 商品分类
	"categoryadd.post": "name:required,url:required",
	"categorydelete.post": "",
	"categoryupdate.post": "_id:required",
	"categorylist.get": "",
	// 通知管理
	"noticeadd.post": "content:required,mode:required",
	"noticedelete.post": "_id:required",
	"noticeupdate.post": "content:required,mode:required",
	"noticelist.get": "",
	// 商品
	"goodsadd.post": "",
	"goodsdelete.post": "",
	"goodsupdate.post": "",
	"goodslist.get": "",
	// 订单模块
	"orderlist.get": "",
	"searchorder.post": "",
	"setsendno.post": "_id:required,sendno:required",
	// 活动模块
	"couponlist.get": "",
	"couponadd.post": "available:required,condition:required,reason:required,value:required,name:required,start:required,end:required,valueDesc:required",
	"couponremove.post": "_id:required",
	// 资金模块
	"paywaterlist.get": "",

}
router.hasRouter = function(path, method) {
	path = path.slice(1).toLowerCase()
	method = method.toLowerCase()
	let other = false
	let has = Reflect.has(router, `${path}.${method}`)

	if (!has) {
		let otherMethod = method == 'get' ? 'post' : 'get'
		other = Reflect.has(router, `${path}.${otherMethod}`)
		has = Reflect.has(router, `${path}`)
	}
	return {
		has,
		other
	}
}
router.rule = function(path = '', method = 'get') {
	// console.log(`${path.slice(1).toLowerCase()}.${method.toLowerCase()}`);
	return router[`${path.slice(1).toLowerCase()}.${method.toLowerCase()}`]
}
module.exports = router;
